#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<queue>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	queue<int>Q;
	for (int i = 0; i < n; i++) {
		Q.push(i + 1);
	}
	int num = 0;
	while (Q.size()) {
		if (num == m - 1) {
			cout << Q.front()<<' ';
			Q.pop();
		}
		else {
			Q.push(Q.front());
			Q.pop();
		}
		num = (num + 1) % m;
	}
	return 0;
}